#ifndef RTU_MASTER_HPP
#define RTU_MASTER_HPP

#include  "ModbusMaster.hpp"

namespace Modbus {

class RTUMaster : public Master {
public:
    class PortableStrategy {
    public:
        virtual ~PortableStrategy() = default;
        virtual bool send(char chr) = 0;
        virtual bool cut(void) = 0;
    };
public:
    explicit RTUMaster(char *buffer,unsigned int buffer_size,PortableStrategy *portable_strategy);
    virtual ~RTUMaster() = default;
    virtual unsigned int sendRequest(int slave_address,const char *buffer,unsigned int length);
    virtual unsigned int receiveResponse(int slave_address,const char *buffer,unsigned int length);
    virtual bool feed(char chr);
    virtual bool cut(void);
protected:
    PortableStrategy *portable_strategy = nullptr;
    char *buffer = nullptr;
    unsigned int buffer_size = 0;
    unsigned int rx_size = 0;
};

}

#endif
